<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/admin/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<base href="<%=basePath%>" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta http-equiv="Cache-Control" content="no-siteapp" />
<link href="assets/css/bootstrap.min.css" rel="stylesheet" />
<link rel="stylesheet" href="css/style.css" />
<link href="assets/css/codemirror.css" rel="stylesheet">
<link rel="stylesheet" href="assets/css/ace.min.css" />
<link rel="stylesheet" href="font/css/font-awesome.min.css" />
<!--[if lte IE 8]>
		  <link rel="stylesheet" href="assets/css/ace-ie.min.css" />
		<![endif]-->
<script src="js/jquery-1.9.1.min.js"></script>
<script src="assets/js/bootstrap.min.js"></script>
<script src="assets/js/typeahead-bs2.min.js"></script>
<script src="assets/layer/layer.js" type="text/javascript"></script>
<script src="assets/laydate/laydate.js" type="text/javascript"></script>
<script src="js/H-ui.js" type="text/javascript"></script>
<title>添加公告</title>
</head>
<body>
	<div class="margin clearfix">
		<div class="article_style">
			<form  id="annfrm">
				<div class="add_content" id="form-article-add">
					<ul>
						<li class="clearfix Mandatory"><label class="label_name"><i>*</i>公告标题</label>
						<span class="formControls col-10">
						<input name="anntitle" type="text" id="form-field-1" class="col-xs-10 col-sm-5 "><span id="stitle"></span>
						</span>
						</li>
						<li class="clearfix"><label class="label_name">公告内容</label> <span class="formControls col-10">
						<script id="editor" name="anncontent" type="text/plain" style="width:100%;height:400px; margin-left:10px;"></script><div id="scon"></div></span></li>
					</ul>
					<input type="hidden" name="adminid" value="1" />
					<div class="Button_operation">
						<input type="text" onclick="check();" class="btn btn-primary radius" value="保存并提交" />
						<!-- <button onclick="article_save();"
							class="btn btn-secondary  btn-warning" type="button">保存草稿</button> -->
						<button onclick="layer_close();" class="btn btn-default radius"
							type="button">&nbsp;&nbsp;取消&nbsp;&nbsp;</button>
					</div>
				</div>
			</form>
		</div>
	</div>
</body>
</html>
<script type="text/javascript"
	src="Widget/ueditor/1.4.3/ueditor.config.js"></script>
<script type="text/javascript"
	src="Widget/ueditor/1.4.3/ueditor.all.min.js">
	
</script>
<script type="text/javascript"
	src="Widget/ueditor/1.4.3/lang/zh-cn/zh-cn.js"></script>
<script type="text/javascript">
function check(){
	var title=$("#form-field-1").val();
	
	$("#stitle").html("");
	if(title==""){
		$("#stitle").html("标题不能为空").css({"color":"red"});;
		return false;
	}
	var ue=UE.getEditor('editor');
	var content=ue.getContent();
	$("#scon").html("");
	if(content==""){
		$("#scon").html("内容不能为空").css({"color":"red"});
		return false;
	}
	article_save_submit();
}
	/**提交操作**/
	function article_save_submit() {
		$.ajax({
			cache : true,
			type : "POST",
			url : '/annount/insertAnnouce',
			data : $('#annfrm').serialize(),// 你的formid
			async : false,
			error : function(request) {
				alert("Connection error");
			},
			success : function(data) {
				if (data) {
					layer.msg('保存成功!', {
						icon : 6,
						time : 1000
					});
					setTimeout(function() {
						location.href = "/annount/selectByExample";
					}, 1000);
				} else {
					layer.msg('保存失败!', {
						icon : 2,
						time : 1000
					});
					return;
				}
			}
		});
	}
	$(function() {
		var ue = UE.getEditor('editor');
	});
	/*radio激发事件*/
	function Enable() {
		$('.date_Select').css('display', 'block');
	}
	function closes() {
		$('.date_Select').css('display', 'none')
	}
	/**日期选择**/
	var start = {
		elem : '#start',
		format : 'YYYY/MM/DD',
		min : laydate.now(), //设定最小日期为当前日期
		max : '2099-06-16', //最大日期
		istime : true,
		istoday : false,
		choose : function(datas) {
			end.min = datas; //开始日选好后，重置结束日的最小日期
			end.start = datas //将结束日的初始值设定为开始日
		}
	};
	var end = {
		elem : '#end',
		format : 'YYYY/MM/DD',
		min : laydate.now(),
		max : '2099-06-16 ',
		istime : true,
		istoday : false,
		choose : function(datas) {
			start.max = datas; //结束日选好后，重置开始日的最大日期
		}
	};
	laydate(start);
	laydate(end);
</script>
